package com.xben.ribbonconsumer.UserCommand;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.xben.ribbonconsumer.service.UserService;
import com.xben.ribbonconsumer.service.UsersService;
import org.apache.tomcat.jni.User;

import java.util.List;

/**
 * @Author: xben
 * @Date: 2019/1/24 13:35
 */
public class UserBatchCommand extends HystrixCommand<List<User>> {
    UsersService usersService;
    List<Long> userIds;

    protected UserBatchCommand(UsersService usersService, List<Long> userIds) {
        super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("usersServiceCommand")));
        this.userIds = userIds;
        this.usersService = usersService;
    }


    @Override
    protected List<User> run() throws Exception {
        return usersService.findAll(userIds);
    }
}
